package com.bawei.database.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.bawei.database.table.VideoEntity

/**
 * Author: Jason Zhang
 * Date: 2024/4/24
 * Desc: 数据库实体操作接口
 */
@Dao
interface VideoDao {

    /**
     * 添加视频数据
     */
    @Insert
    suspend fun addVideos(vararg videos: VideoEntity)

    /**
     * 删除视频数据
     */
    @Delete
    suspend fun delete(vararg videos: VideoEntity)

    /**
     * 更新视频数据
     */
    @Update
    suspend fun updateVideos(vararg videos: VideoEntity)

    /**
     * 分页查找数据
     */
    @Query("select * from video_table order by id limit :pageIndex * :pageSize,:pageSize")
    suspend fun queryVideos(pageIndex: Int, pageSize: Int): List<VideoEntity>

    /**
     * 查询单条数据
     */
    @Query("select * from video_table where id = :videoId")
    suspend fun queryVideoById(videoId: Int): VideoEntity

}